<?php
if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

class Site extends MX_Controller
{

    protected $_currUrl = null;

    function __construct()
    {
        parent::__construct();
        $this->load->model('global_model');
        $this->load->model('sales_customer_model');
        $this->_currUrl = current_url();
        $debug = $this->input->getParam('debug');
        if (intval($debug) == 1) {
            $this->st_registry->register('system/debug', 1);
        } elseif (intval($debug) == -1) {
            $this->st_registry->register('system/debug', -1);
        }
        $is_logged = $this->st_registry->registry('admin/login/success');
        $debug = $this->st_registry->registry('system/debug');
        if (intval($debug) == 1 && !empty($is_logged)) {
            $this->output->enable_profiler(TRUE);
        } else {
            $this->output->enable_profiler(FALSE);
        }
        $act = $this->input->getParam('act');
        if ($act == 'clear') {
            $this->st_registry->clearMemcache();
        }
        global $customer;
        global $is_customer_logged;
        $customer = sales_customer_model::get_current();
        if (!empty($customer)) {
            $is_customer_logged = true;
        } else {
            $is_customer_logged = false;
        }
    }

    protected function _eventLoadLayout()
    {
        return true;
    }

    public function getCurrentUrl()
    {
        return $this->_currUrl;
    }

    public function _renderFormData($keys, $data) {
        foreach ($keys as $key) {
            if (!isset($data[$key])) {
                $data[$key] = '';
            }
        }
        return $data;
    }

}
